home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 4671-5.790 / dmg-5331 / control.s_w / control.doc next >
Text File  |  1994-09-18  |  18KB  |  493 lines

  1.                   Stos Control Extension V3.0
  2.                       Shareware version
  3.                 Copyright L.J.Greenhalgh 1994
  4.  
  5.         These files may be freely  distributed  providing they are not
  6. altered in any way.
  7.  
  8. I am not responsible for  any  damage  which  occurs  to  your ST as a
  9. result of  using  this  extension.Read  the  parallel  instrucion VERY
  10. carefully.
  11.  
  12. If you find this extension  useful  then please consider registering ,
  13. not only will you receive the  lastest  version of the extension , but
  14. you will also receive loads  of  extra  graphics and source which will
  15. enable you to get the  most  out  of  this  extension.I have many more
  16. ideas for commands especially where the  STE  is concerned , but these
  17. will only see the light of day if people register!
  18.  
  19.  
  20. Installation
  21.         Copy the file EXTENSION\CONTROL.EXW into your STOS folder.
  22.         Copy the file EXTENSION\CONTROL.ECW into you Compiler folder.
  23.         Run Stos
  24.  
  25.         STOS may  be  powerful  and  easy  to  learn  but  it  is very
  26. unstructured when compared to  languages  like  C  and GFA basic .This
  27. extension adds a switch construct to STOS which makes program listings
  28. shorter  and   more   readable   as   well   as   many   other  useful
  29. commands.Welcome to the control extension .Come let us enter.....
  30.  
  31.  
  32.         Command Listing
  33.  
  34.         ctrl
  35.         Switch on (INTEGER)
  36.         Case(INTEGER)
  37.         Switch off
  38.         otherwise
  39.         write STRING,ADDRESS
  40.         cmove INTEGER,INTEGER
  41.         cremember
  42.         crecall
  43.         A=add(A,I,L,R)
  44.         A=exist$(FILENAME$+CHR$(0))
  45.  
  46.  
  47.         Parallel port commands
  48.  
  49.         INTEGER=parallel(PORTNUMBER)
  50.         para on
  51.         para off
  52.         INTEGER=para left(PORTNUMBER)
  53.         INTEGER=para right(PORTNUMBER)
  54.         INTEGER=para up(PORTNUMBER)
  55.         INTEGER=para down(PORTNUMBER)
  56.         INTEGER=para fire(PORTNUMBER)
  57.  
  58.         Zone Commands
  59.  
  60.         init megazone STARTZONE,NUMBEROFZONES
  61.         set megazone STARTZONE,ZOMENUMBER,X1,Y1,X2,Y2
  62.         range megazone STARTZONE,LOWERRANGE,UPPERRANGE
  63.         Z=test megazone (STARTZONE,X,Y)
  64.         del megazone STARTZONE
  65.  
  66.  
  67.  
  68.         Screen Commands
  69.  
  70.         screensize WIDTH,HEIGHT
  71.         spread ADDRESS,START_COLOUR,END_COLOUR
  72.         brdr remove TYPE
  73.         hscroll SCREEN,START_Y,END_Y,BITPLANES,NUMBEROFPIXELS
  74.         INTEGER=crack pac SCREEN_ADDRESS,DEST_ADDRESS
  75.         crack unpac SCREEN_ADDRESS,DEST_ADDRESS,MODE
  76.  
  77.         quick screen$ SCREEN,X,Y,STRING,MODE
  78.         image put SCREEN,X,Y,BANK_ADDRESS,NUMBER,MODE
  79.         font SCREEN,X,Y,BANK_ADDRESS,STRING
  80.         set clip X1,X2,Y1,Y2
  81.         INTEGER=font width BANK_ADDRESS
  82.         INTEGER=font height BANK_ADDRESS
  83.         image palette BANK_ADDRESS
  84.  
  85.  
  86.         A switch  construct  is  designed  to   replace  the following
  87. code.For this example suppose we have  a situation where  we  click on
  88. a zone and the result  is  stored  in a  variable  called select.Using
  89. switch as opposed to ON  variable  GOSUB  has  the advantage  that   A
  90. does not have to hold consecutive values.Note we can only switch using
  91. integers.
  92.  
  93. 90 select=zone(0)
  94. 100 flag=false
  95. 110 if select=1 then gosub 1200:flag=true:rem do loading
  96. 120 if select=3 then gosub 4000:flag=true:rem do saving
  97. 130 if select=4 then gosub 500:flag=true:rem .....
  98. 140 if select=7 then gosub 6000:flag=true do something else
  99. 150 if flag=false then gosub 2000:rem well we didnt select 1,3,4 or 7
  100. 160 continue program....
  101.  
  102. This can be replaced by the following code.
  103.  
  104. 90 select=zone(0)
  105. 100 switch on(select)
  106. 110 if case(1) then gosub 1200:ren do loading
  107. 120 if case(3) then gosub 4000:rem so saving
  108. 130 if case(4) then gosub 500:rem ...
  109. 140 if case(7) then gosub 6000:rem so something else
  110. 150 if otherwise then gosub 2000:rem well we didn't select 1,3,4 or 7
  111. 160 switch off
  112.  
  113. switch on (INTEGER)
  114.  
  115.         This stores the value of  the  variable INTEGER in an internal
  116. store for accessing by the  case  and  otherwise commands.You can nest
  117. your case structures up to a depth of 3.
  118.  
  119. Case (INTEGER)
  120.  
  121.         returns a value of true if the value of INTEGER is the same as
  122. that for the preceeding switch on ,otherwise it returns false.
  123.  
  124. otherwise
  125.  
  126.         returns a  value  of  true  if  none  of  the  preceeding case
  127. statements were true otherwise it returns false.
  128.  
  129. switch off
  130.  
  131.         ends the current switch construct.
  132.  
  133. ctrl
  134.  
  135.         Shows  the  command    list.(Thanks   Martin!)   This   is   a
  136. wounderful  idea  , every  extension   should   have  one!  Note  this
  137. does  nothing  in  compiled programs.
  138.  
  139. write STRING,ADDRESS
  140.  
  141.         writes a copy of STRING  starting  at  ADDRESS.Note if you are
  142. using banks then address must  be  the  actual  start of the  bank .eg
  143. write "hello",START(10) not write "hello",10.This provides an easy way
  144. to bypass the infamous STOS string  bug.It  has the advantage over the
  145. copy command in that it will copy strings of non even lengths.
  146.  
  147. So      10 reserve as data 10,10000
  148.         20 write "hello world",start(10)
  149.  
  150. is equivalent to the following.
  151.  
  152.         10 reserve as data 10,1000
  153.         20 s=start(10)
  154.         30 a$="hello world"
  155.         40 al=len$(a$)
  156.         50 for loop=1 to al
  157.         60 poke s+loop-1,asc(mid$(a$,loop,1))
  158.         70 next loop
  159.  
  160. cmove INTEGER,INTEGER
  161.  
  162.         Moves the cursor relative  to  its current postion.Remember to
  163. put a ';' after your print statements otherwise the cursor is moved to
  164. the next line.
  165.  
  166. cremember
  167.  
  168.         Stores the current cursor position in a safe place.
  169.  
  170. crecall
  171.  
  172.         moves the cursor  back  to  its  cremembered  position.These 2
  173. commands mean that you can  write  subroutines which return the cursor
  174. to its origonal position on exit  from  the subrountine.
  175.  
  176. A=add(A,I,L,R)
  177.  
  178. Adds I to A and then  ensures  that  A  is  in  the  range L to R in a
  179. cyclical manner.It is equivalent to the following code
  180.  
  181.         10 A=A+I
  182.         20 if A<L then A=R
  183.         30 if A>R then A=L
  184.  
  185. A=exist$(FILENAME$+CHR$(0))
  186.  
  187. Returns true if the file FILENAME$ exists  at the current path , false
  188. if it does not.
  189.  
  190.  
  191.                 Parallel Joystick Commands
  192.  
  193. Para on/Para off
  194.         Initialise/Deactivate parallel port adaptor.
  195.  
  196. J=parallel(0-1)
  197.  
  198.         Remember those joystick   adaptors   which   plugged  into the
  199. parallel port and were  used in   games  like Gauntlet II enabling you
  200. to have 4 players.  Well   now   you   can   read   them  from STOS. J
  201. is returned in the following way  with   the   following bits set to 1
  202. if you are performing that action.
  203.  
  204.         bit     0       Up
  205.         bit     1       Down
  206.         bit     2       Left
  207.         bit     3       Right
  208.         bit     4       Fire
  209.  
  210.         Because of the fact   that   one   single   chip   in  the  ST
  211. controls the printer,sound chip  and  discdrive  ,  using this command
  212. will deactivate the disc  drive  (harddrives are  unaffected).The para
  213. on command stores the current state  of  the  sound chip ie before the
  214. disc drive is turned off by the parallel command.Using  the  para  off
  215. command restores the  sound  chip  register  to   its  original  value
  216. thus  restoring the disc drive.
  217.  
  218.         So whenever you want to   use   the  floppy  drive after using
  219. the parallel command  ,  use   para   off.If   all   else  fails  type
  220. 'boom' or  'shoot'  as  this  also  reinitialises   the  discdrive.The
  221. reason I didn't store and  restore  the  status  of the discdrive from
  222. within the parallel command  is  that  it  would   further  slow  down
  223. what is already quite a slow process.
  224.  
  225. eg.
  226.         10 para on:rem save sound chip register
  227.         .
  228.         .
  229.         1000 p=parallel(0):rem this will deactivate discdrive
  230.         .
  231.         .
  232.         2000 para off:rem we can now use the floppy drive again.
  233.  
  234.  
  235. INTEGER=para right(0-1)
  236.         Returns true if the joystick is currently being moved right.
  237.  
  238. INTEGER=para left(0-1)
  239.         Returns true if the joystick is currently being moved left.
  240.  
  241. INTEGER=para up(0-1)
  242.         Returns true if the joystick is currently being moved up.
  243.  
  244. INTEGER=para down(0-1)
  245.         Returns true if the joystick is currently being moved down.
  246.  
  247. INTEGER=para fire(0-1)
  248.         Returns true if the joystick fire button is currently pressed.
  249.  
  250.         Using the parallel commands with STOS Maestro Samples
  251.  
  252. If you want to use  STOS  maestro  samples  with the parallel commands
  253. then make sure that the keyboard click is turned off and that you have
  254. used the sound init command first eg
  255.  
  256.         10 click off:sound init:para on
  257.  
  258.  
  259. spread SCREEN_ADDRESS,START_COLOUR,END_COLOUR
  260.  
  261. spread will  produce  graduated  shades  between  the  colour  indexes
  262. START_COLOUR and END_COLOUR.eg if colour 1  was  $111 and colour 7 was
  263. $777  then  spread  logic,1,7  would   produce  the  following  colour
  264. values.Note that this will not  work  correctly  on colours which have
  265. the STE's extra bits set.
  266.  
  267.         colour 1= $111
  268.         colour 2= $222
  269.         colour 3= $333
  270.         colour 4= $444
  271.         colour 5= $555
  272.         colour 6= $666
  273.         colour 7= $777
  274.  
  275.  
  276. brdr remove TYPE  (STFMs only!)
  277. Will remove selected borders depending on the value of TYPE.
  278.  
  279. TYPE=0 return borders to normal
  280. TYPE=1 bottom border only.
  281. TYPE=2 top border.
  282. TYPE=3 both border!
  283.  
  284. When using this  command  you  can  only  read  the  keyboard by using
  285. HARDKEY command from the misty extension  or by peeking the value from
  286. $FFFC02.
  287.  
  288.  
  289.         Zone Commands
  290.  
  291. Ever think that 128 zones were too little? well now you can have up to
  292. 65536 zones for collison detection.
  293.  
  294.  
  295. init mega zone START_ADDRESS,NUMBEROFZONES
  296.  
  297. Set up replacement zones.You must  reserve  space for your zones using
  298. either a memory bank or a string  and  then put the start address into
  299. STARTZONE, the amont of  space  you  need  can  be calculated by space
  300. =8+NUMBEROFZONES*8.
  301.  
  302.  
  303. set megazone START_ADDRESS,ZONENUMBER,X1,Y1,X2,Y2
  304.  
  305. creates a  rectangular  zone  ,ZONENUMBER  with  coordinates  X1,Y1 to
  306. X2,Y2.
  307.  
  308. INTEGER=test negazone (START_ADDRESS,X,Y)
  309.  
  310. Gives you the first zone  which contains coordinates X and Y.
  311.  
  312. range megazone START_ADDRESS,ZONE_S,ZONE_E
  313.  
  314. Limits subsequent test megazones to  a  subset of the total number of
  315. zones .This means you can create  control  panels which can have over-
  316. lapping zones and just test the few you are interestred in.If you want
  317. to reset the tests to the default range use
  318.  
  319.       range megazone START_ADDRESS,1,NUMBEROFZONES
  320.  
  321. del megazone START_ADDRESS
  322.  
  323. Deletes all the zones or a subset if you have used range megazone.
  324.  
  325.  
  326. hscroll SCREEN_ADDRESS,YSTART,YEND,BITPLANES,NUMBEROFPIXELSTOSCROLL
  327.  
  328. STOS' horizontal scrolling is  appalling  ,  this  command attempts to
  329. redress the balance . SCREEN_ADDRESS is as usual . YSTART is the first
  330. line to start the scroll on , YEND is the line to finish the scroll on
  331. .BITPLANES is the pattern of bitplanes  to  scroll ie %1 , just scroll
  332. bitplane 1, %1111 scroll them all  . NUMBER_OF_PIXELS is the number of
  333. pixels to scroll by , if  this  number  is positive then the screen is
  334. scrolled to the right otherwise it  is  scrolled to the left.Note that
  335. you can only use this command on regular 320 x 200 sized screens.
  336.  
  337.  
  338.  
  339. crack unpac BANK_ADDRESS,SCREEN_ADDRESS,MODE
  340.  
  341.         Crack Art is a  wounderful  art  package  and these 2 commands
  342. allow you to pack and unpack  lowrez  crack art screens . BANK_ADDRESS
  343. and SCREEN_ADDRESS are as normal,  if  MODE=0  then the palette of the
  344. current screen is not altered , if MODE<>0 then it is.
  345.  
  346. LENGTH=crack pac SCREEN_ADDRESS,BANK_ADDRESS
  347.  
  348.         As for the STOS pack command
  349.  
  350.         The control extension now  includes  a  complete sprite engine
  351. which is much faster  than  STOS's  existing  one  .  It is similar in
  352. nature to the Missing Link's engine  although it is much more flexible
  353. in that you have a variety of choices in how the sprites are placed on
  354. the screen and it is fully compatible with the large hardware scrolled
  355. screens avalaible  on  the  STE  .  The  banks  and  however  are  not
  356. compatible with either STOS sprite mbk's or the missing links mbk's or
  357. ICBIS's mbk's.
  358.  
  359.  
  360. screen size WIDTH,HEIGHT
  361.  
  362.         This informs the sprite engine what  size screens you have set
  363. up for the STE's hardware  scrolling  .The  parameters are the same as
  364. for the hard screensize command from the  STE extension . Dont try and
  365. grab screen$ when using screens which  are  not  the usual 320 x 200 ,
  366. because STOS itself is unaware is  that  the screen size has changed ,
  367. in fact don't try any of STOS's  graphics commands on screens that are
  368. not 320 x 200 as you will get very strange results.
  369.  
  370. quick screen$ SCREEN,X,Y,STRING,MODE
  371.  
  372.         Puts a string stored in  screen$  format  onto the screen much
  373. faster than its STOS equivalent , plus  you can place it on the screen
  374. in either transparent or replace form as well as chooseing  whether to
  375. flip it vertically in  real  time  as  you  plot  it.These options are
  376. activated by setting various bits  in  MODE  .
  377. bit 0=0 use replace mode
  378.     0=1 use transparent mode
  379.     1=0 don't flip vertically
  380.     1=1 flip vertically
  381.  
  382. By using the set clip command you can activate a clipping region .
  383.  
  384.  
  385. image put SCREEN_ADDRESS,X,Y,IMAGE_BANK_ADDRESS,IMAGE_NUMBER,MODE
  386.  
  387.         Puts an image NUMBER from  bank  BANK_ADDRESS  onto the screen
  388. SCREEN_ADDRESS using  the  MODE  options  from  above.Use  the program
  389. maker.bas to make these banks.This is a similar command to the Missing
  390. Link's Bob command although  it  is  slightly  slower  it has far more
  391. flexibilty in that you don't  have  to  store  both up and down facing
  392. sprites . This is the only sprite  routine avaliable for STOS which is
  393. compatible with the  STE's  hardware  scrolling  in  that  it works on
  394. screens of many different sizes. You  can  have  up to 65536 images in
  395. your bank!
  396.  
  397. font SCREEN_ADDRESS,X,Y,IMAGE_BANK_ADDRESS,TEXT$
  398.  
  399.         writes a 16 colour font  to  the  screen SCREEN_ADDRESS at the
  400. coordinates X,Y using the images  from IMAGE_BANK.Make sure that text$
  401. is in upper case! Use the program maker.bas to make these banks.
  402. eg.
  403.  
  404.         font logic,0,0,start(10),"HELLO"
  405.  
  406. Note that if you  include  a  chr$(23)  in  your  text string then the
  407. 'graphic' cursor will move to the beginning of the next line.
  408.  
  409.  
  410. INTEGER=image height BANK_ADDRESS
  411.         Gets the height of all the images in the image bank.
  412.  
  413. INTEGER=image width BANK_ADDRESS
  414.         Gets the width of all the images in the image bank.
  415.  
  416. image palette BANK_ADDRESS
  417.         Gets the palette from an image bank.
  418.  
  419. set clip X1,Y1,X2,Y2
  420.  
  421.         Sets the clipping rectangle for the  quick screen$ , image put
  422. and font commands . Note  that  the  X  coordinates are rounded to the
  423. nearest multiple of 16.
  424.  
  425.  
  426. many image SCREEN_ADDRESS,BANK_ADDRESS,FIRST_XCOORD_ADDRESS,
  427.            FIRST_YCOORD_ADDRESS,FIRST_IMAGE_NUMBER_ADDRESS,
  428.            NUMBER_TO_PLOT
  429.  
  430.         This plots a large number of images  in one go .The images are
  431. all plotted in transparent mode . If bit  31 of an image number is set
  432. then the image is flipped vertically  when  it is plotted.If any image
  433. number is 0 then that image is not plotted.
  434.  
  435. eg.
  436.  
  437. 10 mode 0:key off:curs off:hide:flash off
  438. 15 dim x(10),y(10),i(10)
  439. 20 load "font.mbk",10:st=start(10)
  440. 30 for loop=1 to 10
  441. 40 x(loop)=loop*32:y(loop)=0:i(loop)=loop
  442. 50 next loop
  443. 60 many image logic,st,varptr(x(1)),varptr(y(1)),varptr(i(1)),10
  444.  
  445.  
  446.         Well there  you have  it.  I    would   like   to thank Martin
  447. Cubbit for his excellent  articles  in  the  Stosser  diskzine   which
  448. provided valuable  guidence   in   writing   this    extension.
  449.  
  450. Registration
  451.         If you would  like  to   register   for   this  extension then
  452. please send a 5 UK pound cheque/postal  order or cash to the following
  453. address .
  454.  
  455.         L.J.Greenhalgh
  456.         24 Park Avenue,
  457.           Rudloe Manor,
  458.                Corsham,
  459.                  Wilts,
  460.               SN13 OJT.
  461.                England.
  462.  
  463.         email   ma2ljg@ss1.bath.ac.uk       (valid until june 1995)
  464.  
  465.  
  466.  
  467.  
  468.  
  469. +----------------------------------------------------------+
  470. |Please except my registration for the control extension   |
  471. +----------------------------------------------------------+
  472. |I wish to pay by cash/cheque/postal order                 |
  473. +----------------------------------------------------------+
  474. |Machine owned                                             |
  475. +----------------------------------------------------------+
  476. |Bugs                                                      |
  477. |                                                          |
  478. |                                                          |
  479. +----------------------------------------------------------+
  480. |Ideas for new commands                                    |
  481. |                                                          |
  482. |                                                          |
  483. +----------------------------------------------------------+
  484. |Please send my registration package to:                   |
  485. |                                                          |
  486. |                                                          |
  487. |                                                          |
  488. |                                                          |
  489. |                                                          |
  490. |                                                          |
  491. |                                                          |
  492. +----------------------------------------------------------+
  493.